/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { $string = String::findHashidOrFail($id); if (count($string) > 1) { return $this->response->collection($string, new StringTransformer()); } return $this->response->item($string, new StringTransformer()); }
protected function makeString($uri, $key, $value, $plural = null, $comment = null, $placeholders = null) { $source_id = $this->source->id; $locale = $this->locale; $uri = String::makeUri($uri); $string = String::firstOrNew(compact('locale', 'uri', 'source_id')); $string->fill(compact('key', 'value', 'plural', 'comment', 'placeholders'))->save(); $this->strings[] = $string; return $this; }
/** * Run the database seeds. * * @return void */ public function run() { DB::table('sources')->delete(); DB::table('strings')->delete(); $source = ['locale' => 'en', 'format' => 'twine', 'path' => null]; $source = Source::create($source); $strings = ['save' => 'Save', 'load' => 'Load', 'new' => 'New', 'open' => 'Open', 'close' => 'Close', 'ok' => 'OK', 'cancel' => 'Cancel', 'delete' => 'Delete']; foreach ($strings as $key => $value) { $string = ['key' => $key, 'uri' => 'basic.' . $key, 'value' => $value, 'locale' => 'en', 'source_id' => $source->id]; $string = String::create($string); } }
/** * Bootstrap any application services. * * @return void */ public function boot() { $user = Auth::user() ?: User::whereEmail('system@twine')->first(); Repository::creating(function ($model) use($user) { $model->created_by = $user->id; }); Project::creating(function ($model) use($user) { $model->created_by = $user->id; }); String::creating(function ($model) use($user) { $model->created_by = $user->id; }); Source::creating(function ($model) use($user) { $model->created_by = $user->id; }); }