コード例 #1
0
ファイル: StringsController.php プロジェクト: kitbs/twine
 /**
  * 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());
 }
コード例 #2
0
ファイル: AbstractFileFormat.php プロジェクト: kitbs/twine
 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;
 }
コード例 #3
0
ファイル: SourceStringSeeder.php プロジェクト: kitbs/twine
 /**
  * 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);
     }
 }
コード例 #4
0
ファイル: AppServiceProvider.php プロジェクト: kitbs/twine
 /**
  * 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;
     });
 }